package com.bw.flinkstreaming.source.bw1;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;

/**
 * 需求：从集合生成数据源
 * */
public class Job1 {
    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        ArrayList<String> data = new ArrayList<String>();
        data.add("flink1");
        data.add("flink1");
        data.add("flink1");
        DataStreamSource<String> stringDataStreamSource = env.fromCollection(data);
        SingleOutputStreamOperator<String> map = stringDataStreamSource.map(new MapFunction<String, String>() {
            @Override
            public String map(String value) {
                return value;
            }
        });

        map.print().setParallelism(1);
        env.execute("job1");
    }
}
